import {
  SESSION_MAXHEIGHT_KEY,
  SESSION_MAXHASH_KEY
} from '@/config/contants.js'

const mutations = {
  updateMaxHeight(state, Height) {
    state.maxHeight = Height
    sessionStorage.setItem(SESSION_MAXHEIGHT_KEY, Height)
    // 浏览器会持续更新节点的高度，如果重新连接上节点，可认为已恢复连接
    if (state.connectStatus !== true) {
      state.connectStatus = true
    }
  },
  updateMaxBlockHash(state, hash) {
    state.maxHash = hash
    sessionStorage.setItem(SESSION_MAXHASH_KEY, hash)
  },
  updateTokenList(state, list) {
    state.tokenList = list
    state.tokenListSuccess = true
  },
  updateLang(state, lang) {
    state.initLang = lang
    localStorage.setItem('BLOCK_LANG', lang)
  }
};

export default mutations;